var V=readkeyfile(lpusername);if(!V){lpshowError("LoginError",false,true);return}V=load_accounts_file(lpusername_hash,true,false);if(!V){lpshowError("LoginError",false,true);return}V=V.substring(0,1200);if(V.indexOf("type=sesameoffline\ndata=")>=0){var f="";while(true){f=sesame_getotp(null);if(f==""||f.length!=64){if(f.length>64){LP.alert(LP.lpgs("SesameWrongButton"));
LP.flush_prefs();if(!lphidewelcome){LP.OpenCreateAccount()}}lpLoginCheckErrorHandler(k,"noexistingsession");return}lpReportError("login_check.php returned invalid response text="+y.responseText);lpLoginCheckErrorHandler(k,"invalidresponse");return}lppwdeckey=lp_hex2bin(lp_sha256(p[0].getAttribute("pwdeckey")));
var a=LP.lpprefsHasUserValue("logOffWhenCloseBrowserVal")?LP.lpprefsGetIntPref("logOffWhenCloseBrowserVal"):0;var r=lp_get_gmt_timestamp()-i;if(r>=a*60){lplogoff();return}}var b;if(lp_local_key==""){var l=readenckeyfromkeyfile(lpusername);if(!l){lpLoginCheckErrorHandler(k,"nokeyfileA");return}b=lp_hex2bin(lpdec(l,lppwdeckey,true));
var c=readkeyfile(lpusername,b);if(!c){lpLoginCheckErrorHandler(k,"nokeyfileB");return}}if(k=="httptest"){var s=(p[0].getAttribute("sesamepassword")!=null&&p[0].getAttribute("sesamepassword")!="")?true:false;var t=(p[0].getAttribute("yubikeyenabled")!=null&&p[0].getAttribute("yubikeyenabled")=="1")?true:false;
var h=(p[0].getAttribute("multifactorenabled")!=null&&p[0].getAttribute("multifactorenabled")!="")?true:false;var m=(p[0].getAttribute("sesameotpok")!=null&&p[0].getAttribute("sesameotpok")!="")?true:false;var u=(p[0].getAttribute("yubikeyotpok")!=null&&p[0].getAttribute("yubikeyotpok")!="")?true:false;
var z=(p[0].getAttribute("multifactorresponseok")!=null&&p[0].getAttribute("multifactorresponseok")!="")?true:false;if(s){if(m){}else{var q=sesame_getotp(lpusername);if(q==""){lplogoff();lpshowError("LoginError",false,true);return}var d=sesame_getdata("logincheckpostdata")+"&sesameotp="+encodeURIComponent(q);
var R=grid_getdata("from");if(grid_getdata("label")){Y+="&trustlabel="+LP.en(grid_getdata("label"))}if(b[0].getAttribute("wxsessid")){Y+="&wxsessid="+LP.en(b[0].getAttribute("wxsessid"))}LP.lpMakeRequest(LP.lp_base+"login.php",Y,lpLoginResponse,function(){lpLoginErrorHandler(R)},R);return}if(Q&&Q.indexOf("gridresponsefailed")>0){LP.lpClearCache(true,false,false);
return}lpReportError("login.php returned invalid response text="+a.responseText);lpLoginErrorHandler(W);return}lppwdeckey=lp_hex2bin(lp_sha256(Z[0].getAttribute("pwdeckey")));lpusername=Z[0].getAttribute("lpusername");lpusername_hash=lp_sha256(lpusername);lpuid=Z[0].getAttribute("uid");lpWriteKeyFile();
lpLoginCommon(Z,W,false)}catch(d){lpReportError("Failure in lpLoginResponse: "+d+" ln: "+d.lineNumber);lpLoginErrorHandler(W)}}function lpLoginCommon(U,T,N){lploggedinoffline=false;if(N==null||typeof(N)=="undefined"){N=true}if(lpnotifytimerid){LP.mostRecent().clearTimeout(lpnotifytimerid);lpnotifytimerid=null
if(lpversion!=""&&O!=""&&CompareLastPassVersions(lpversion,O,V)<0){LP.alert(LP.lpgs("A required update is available for LastPass. Please press OK to begin download and installation."));LP.lpUpdate()}}catch(S){}OnAllLogins();lppopulateaccountsfromlogin=true;lpGetAccountsLocal();if(T=="pluginlogin"||T=="createaccount"){lprefreshwindows()
var F=G.getElementsByTagName("ok");if(F.length>0){var H=F[0].getAttribute("lastpass");if(H=="1"){LP.lplogincheck("httptest");return}}}httptesterror()}}catch(I){httptesterror()}}function httptesterror(){LP.setTimeout(function(){LP.httptest()},300000)}function get_multifactor_disable_url(D,C){return"multifactordisable.php?cmd=sendemail&username="+encodeURIComponent(D)+"&type="+encodeURIComponent(C)